<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class checkuplog extends CI_Controller {

	/**
	 * Index Page for this controller.
	 *
	 * Maps to the following URL
	 * 		http://example.com/index.php/welcome
	 *	- or -  
	 * 		http://example.com/index.php/welcome/index
	 *	- or -
	 * Since this controller is set as the default controller in 
	 * config/routes.php, it's displayed at http://example.com/
	 *
	 * So any other public methods not prefixed with an underscore will
	 * map to /index.php/welcome/<method_name>
	 * @see http://codeigniter.com/user_guide/general/urls.html
	 */
	public function __construct() {
		parent::__construct();
		ini_set('session.cookie_httponly',1); 
		ini_set('session.use_only_cookies',1);
		$this->load->model('checkuplog_class');
		$this->load->model('user_class');		
	}	 
	public function save_checkuplog(){
		$post = $this->input->post();
		$a = @split('%3D', @base64_decode($post['intUserID']));
		if($a[0]=='user_id'){
			$post['intUserID'] = $a['1'];
		}
		$message = '';
		$checkuplog = $this->checkuplog_class->get_checkuplog($post);
		//$test=$this->db->last_query();
		if($checkuplog!=0){
			$message = $this->checkuplog_class->update($post);
		} else {
			$message = $this->checkuplog_class->insert($post);
		}
		//$message['qry'] = $test;
		echo json_encode($message);
	}
	public function list_checklupog(){
		$post = $this->input->post();
		$data=array();
		$a = @split('%3D', @base64_decode($post['intUserID']));
		if($a[0]=='user_id'){
			$post['intUserID'] = $a['1'];
		}		
		$checkuplog_list = $this->checkuplog_class->list_checkuplog($post);
		//$data['qry']=$this->db->last_query();
		if($checkuplog_list!=0){
			foreach($checkuplog_list as $key=>$value){
// 				$data['intID'][$key]=$value['intID'];
// 				$data['strNoteTitle'][$key]=$value['strNoteTitle'];
// 				$data['dateNoteDate'][$key]=date('m/d/y',strtotime($value['dateNoteDate']));
// 				$data['dateNoteDateDB'][$key]=date('Y-n-j',strtotime($value['dateNoteDate']));
// 				$data['strNotes'][$key]=$value['strNotes'];
				$data['strUserName'][$key]='';
				$data['intID'][$key]=$value['intID'];
				$data['intUserID'][$key]=$value['intUserID'];
				$post['intUserID']=$value['intUserID'];
				$user = $this->user_class->get_user_data($post);
				if($user!=0){
					$data['strUserName'][$key]=$user['strName'];
				}
				$data['strNoteTitle'][$key]=$value['strNoteTitle'];
				$data['strCreatedBy'][$key]=$value['strCreatedBy'];
				$data['dateNoteDate'][$key]=date('m/d/y',strtotime($value['dateNoteDate']));
				$data['dateNoteDateDB'][$key]=date('Y-n-j',strtotime($value['dateNoteDate']));
				$data['strNotes'][$key]=$value['strNotes'];
			}
		}
		echo json_encode($data);
	}
	public function get_checklupog(){
// 		$post = $this->input->post();
// 		$checkuplog = $this->checkuplog_class->get_checkuplog($post);
// 		echo json_encode($checkuplog);
		$post = $this->input->post();
		$a = @split('%3D', @base64_decode($post['intUserID']));
		if($a[0]=='user_id'){
			$post['intUserID'] = $a[1];
		}
		$checkuplog = $this->checkuplog_class->get_checkuplog($post);
		echo json_encode($checkuplog);
	}
	public function delete_checklupog(){
		$post = $this->input->post();
		$checkuplog = $this->checkuplog_class->delete($post);
		echo json_encode($checkuplog);
	}	
}

/* End of file welcome.php */
/* Location: ./application/controllers/welcome.php */